package com.ews.onlineexchange.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.Field;

/**
 * 实体名称：采购方，采购服务的用户 说明：有独特的信息发布权限
 * 
 * @author wcq
 *
 */
@Entity
@Analyzer(impl = SmartChineseAnalyzer.class)
public class ServiceBuyer extends User {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

	private String				creditCode;					// 组织机构代码/统一信用代码
	private String				legalPerson;				// 法定代表人
	private String				legalPersonPhoneNumber;		// 法人电话号码
	private String				firstContactor; 			// 第一联系人
	private String				firstContactorPhoneNumber;	// 第一联系人电话
	private String				secondContactor;			// 第二联写人
	private String				secondContactorPhoneNumber;	// 第二联写人电话
	private String				address;					// 地址
	private String				buyerType			= "个人";	// 用户类型（例如：个人或公司单位，）

	@NotNull
	@Column(unique = true)
	public String getCreditCode() {
		return creditCode;
	}

	public void setCreditCode(String creditCode) {
		this.creditCode = creditCode;
	}

	@NotNull
	public String getLegalPerson() {
		return legalPerson;
	}

	public void setLegalPerson(String legalPerson) {
		this.legalPerson = legalPerson;
	}

	@NotNull
	@Pattern(regexp = "(1\\d{10}|(\\d{3,4}-)?\\d{7,8}(-\\d{1,4})?)+", message = "请输入正确格式的电话号码：手机号或【3-4位区号】-【7-8位电话号码】-【1-4位】分机号")
	public String getLegalPersonPhoneNumber() {
		return legalPersonPhoneNumber;
	}

	public void setLegalPersonPhoneNumber(String legalPersonPhoneNumber) {
		this.legalPersonPhoneNumber = legalPersonPhoneNumber;
	}

	@Field
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getBuyerType() {
		return buyerType;
	}

	public void setBuyerType(String buyerType) {
		this.buyerType = buyerType;
	}

	@NotNull
	public String getFirstContactor() {
		return firstContactor;
	}

	public void setFirstContactor(String firstContactor) {
		this.firstContactor = firstContactor;
	}

	@NotNull
	@Pattern(regexp = "(1\\d{10}|(\\d{3,4}-)?\\d{7,8}(-\\d{1,4})?)+", message = "请输入正确格式的电话号码：手机号或【3-4位区号】-【7-8位电话号码】-【1-4位】分机号")
	public String getFirstContactorPhoneNumber() {
		return firstContactorPhoneNumber;
	}

	public void setFirstContactorPhoneNumber(String firstContactorPhoneNumber) {
		this.firstContactorPhoneNumber = firstContactorPhoneNumber;
	}

	public String getSecondContactor() {
		return secondContactor;
	}

	public void setSecondContactor(String secondContactor) {
		this.secondContactor = secondContactor;
	}

	public String getSecondContactorPhoneNumber() {
		return secondContactorPhoneNumber;
	}

	public void setSecondContactorPhoneNumber(String secondContactorPhoneNumber) {
		this.secondContactorPhoneNumber = secondContactorPhoneNumber;
	}

}
